package com.googlecode.continuity.plugin.codecomment.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
import com.googlecode.continuity.core.client.CoreGWT;
import com.googlecode.continuity.core.client.rpc.RPCCreationCallback;

/**
 * CodeCommentInit
 *
 * @author Peter Schmitt <aragos@aragos.de>
 */
public class CodeCommentInit implements EntryPoint {
  public void onModuleLoad() {
    //register rpc
    CoreGWT.registerRPC("CodeCommentRPCAsync", new RPCCreationCallback() {
      public Object createRPC() {
        CodeCommentRPCAsync codeCommentRpc = (CodeCommentRPCAsync) GWT.create(CodeCommentRPC.class);
        ServiceDefTarget endpoint = (ServiceDefTarget) codeCommentRpc;
        String moduleRelativeURL = CoreGWT.getWebappRoot() + "codecomment.rpc";
        endpoint.setServiceEntryPoint(moduleRelativeURL);
        return codeCommentRpc;
      }
    });

    // ensure enum availability
    for (int i = 0; i < SeverityConstant.getInstances().size(); i++) {
      String tmp = ((SeverityConstant) SeverityConstant.getInstances().get(i)).getName();
    }
  }
}
